Gun Violence Analysis — Country-Level & US County-Level Report

Data Collection

01 — Data Collection & Cleaning

Fetch gun homicide rates, population, Gini coefficients, and drug offense rates.

Merge all datasets on ISO alpha-3 country codes and output a combined CSV.

Fetch Individual Datasets

Gun homicide data: 161 countries
country_code country_name gun_homicide_rate
0 AFG Afghanistan 4.7
1 ALB Albania 1.3
2 DZA Algeria 0.5
3 AGO Angola 4.8
4 ARG Argentina 2.2
Using embedded population fallback data
Population data: 169 countries
country_code country_name population
0 AFG Afghanistan 41128771
1 ALB Albania 2842321
2 DZA Algeria 44903225
3 AGO Angola 34503774
4 ARG Argentina 46234830
Using embedded Gini fallback data
Gini data: 152 countries
country_code country_name gini
0 ALB Albania 30.0
1 DZA Algeria 27.6
2 AGO Angola 51.3
3 ARG Argentina 42.3
4 ARM Armenia 29.9
Drug offense data: 121 countries
country_code country_name drug_offense_rate
0 ALB Albania 45.0
1 DZA Algeria 85.0
2 ARG Argentina 102.0
3 ARM Armenia 38.0
4 AUS Australia 605.0
Gun ownership data: 162 countries
country_code country_name guns_per_100
0 AFG Afghanistan 12.5
1 ALB Albania 8.6
2 DZA Algeria 7.1
3 AGO Angola 3.0
4 ARG Argentina 10.2
Gun control strictness data: 162 countries
country_code country_name gun_control_strictness
0 AFG Afghanistan 1
1 ALB Albania 3
2 DZA Algeria 4
3 AGO Angola 3
4 ARG Argentina 3

Merge All Datasets

Merged dataset: 161 countries
country_code country_name gun_homicide_rate population gini drug_offense_rate guns_per_100 gun_control_strictness region
0 AFG Afghanistan 4.70 41128771 NaN NaN 12.5 1.0 Sub-Saharan Africa
1 ALB Albania 1.30 2842321 30.0 45.0 8.6 3.0 Eastern Europe
2 DZA Algeria 0.50 44903225 27.6 85.0 7.1 4.0 Middle East & N. Africa
3 AGO Angola 4.80 34503774 51.3 NaN 3.0 3.0 Sub-Saharan Africa
4 ARG Argentina 2.20 46234830 42.3 102.0 10.2 3.0 South America
5 ARM Armenia 0.40 2780469 29.9 38.0 4.4 3.0 Eastern Europe
6 AUS Australia 0.15 25978935 34.3 605.0 13.7 4.0 Oceania
7 AUT Austria 0.15 9041851 30.5 340.0 30.0 3.0 Western Europe
8 AZE Azerbaijan 0.60 10093121 26.6 42.0 3.6 4.0 Eastern Europe
9 BHS Bahamas 24.50 409984 NaN 310.0 5.3 3.0 Central America & Caribbean

Data Coverage Summary

Countries with ALL six metrics: 118

Metric Countries with data
0 Gun Homicide Rate 161
1 Population 161
2 Gini Coefficient 147
3 Drug Offense Rate 121
4 Gun Ownership 160
5 Gun Control Strictness 160

Save Merged Dataset

Saved merged data to ../data/processed/merged_country_data.csv
Shape: (161, 9)
gun_homicide_rate population gini drug_offense_rate guns_per_100 gun_control_strictness
count 161.000000 1.610000e+02 147.000000 121.000000 160.000000 160.000000
mean 3.423416 4.870290e+07 38.012925 131.958678 9.805000 3.212500
std 5.742088 1.620168e+08 8.084056 128.537050 13.089344 0.788179
min 0.000000 2.812000e+05 24.600000 8.000000 0.200000 1.000000
25% 0.350000 4.614974e+06 32.100000 42.000000 2.000000 3.000000
50% 1.400000 1.122882e+07 36.700000 85.000000 5.400000 3.000000
75% 3.500000 3.640882e+07 42.900000 175.000000 12.350000 4.000000
max 33.300000 1.417173e+09 63.000000 605.000000 120.500000 5.000000

Gun Homicide Map

02 — Gun Homicide Rate Choropleth Map

World map colored by gun homicide rate per 100K, plus top/bottom 20 bar charts.

Loaded 161 countries

World Choropleth — Gun Homicide Rate per 100K

Summary Statistics

Gun Homicide Rate (per 100K) — Summary Statistics
  Mean:   3.42
  Median: 1.40
  Std:    5.74
  Min:    0.00 (Iceland)
  Max:    33.30 (Venezuela)

Top 20 Countries by Gun Homicide Rate

Bottom 20 Countries (Lowest Gun Homicide Rate)


Gini Correlation

03 — Gun Homicide vs Gini Coefficient

Scatter plot with trend line exploring the correlation between income inequality (Gini) and gun homicide rates.

Countries with both Gini and gun homicide data: 147

Scatter Plot — Gun Homicide Rate vs Gini Coefficient

Linear regression (Gini vs log10 gun homicide rate):
  R² = 0.3588
  p-value = 1.10e-15
  slope = 0.0537

Gini Coefficient Choropleth (Reference)


Drug Correlation

04 — Gun Homicide vs Drug Offenses

Scatter plot with trend line exploring the correlation between drug offense rates and gun homicide rates.

Countries with both drug offense and gun homicide data: 121

Scatter Plot — Gun Homicide Rate vs Drug Offense Rate

Linear regression (log drug offense vs log gun homicide):
  R² = 0.0281
  p-value = 6.59e-02
  slope = -0.3093

Drug Offense Rate Choropleth (Reference)


Population Correlation

05 — Gun Homicide vs Population

Scatter plot with trend line exploring the correlation between country population and gun homicide rates.

Countries with both population and gun homicide data: 161

Scatter Plot — Gun Homicide Rate vs Population

Linear regression (log population vs log gun homicide rate):
  R² = 0.0000
  p-value = 9.60e-01
  slope = -0.0042

Gun Ownership Correlation

06 — Gun Homicide vs Gun Ownership Rate

Scatter plot with trend line exploring the correlation between civilian gun ownership

(firearms per 100 persons, Small Arms Survey 2017) and gun homicide rates.

Countries with both gun ownership and gun homicide data: 160

Scatter Plot — Gun Homicide Rate vs Gun Ownership

Linear regression (guns per 100 vs log10 gun homicide rate):
  R² = 0.0064
  p-value = 3.16e-01
  slope = -0.0044

Gun Ownership Choropleth Map


Gun Control Correlation

07 — Gun Homicide vs Gun Control Strictness

Scatter plot, strip plot, and trend line exploring the correlation between gun control

strictness (custom ordinal scale 1-5) and gun homicide rates.

**Scale:** 1 = Very Permissive, 2 = Permissive, 3 = Moderate, 4 = Strict, 5 = Very Strict

Countries with both gun control strictness and gun homicide data: 160

Scatter Plot — Gun Homicide Rate vs Gun Control Strictness

Linear regression (gun control strictness vs log10 gun homicide rate):
  R² = 0.2085
  p-value = 1.29e-09
  slope = -0.4222

Strip / Box Plot — Homicide Rate Distribution by Strictness Level

Gun Control Strictness Choropleth Map


Us Data Collection

08 — US County-Level Data Collection & Cleaning

Fetch gun homicide rates, population, Gini, drug offenses, poverty, income, gun ownership, and gun law grades

for ~100 of the largest US counties. Merge all datasets on 5-digit FIPS codes and output a combined CSV.

Fetch Individual Datasets

Gun homicide data: 101 counties
fips county_name state gun_homicide_rate
0 06037 Los Angeles County CA 7.2
1 17031 Cook County IL 14.5
2 48201 Harris County TX 12.8
3 04013 Maricopa County AZ 7.1
4 06073 San Diego County CA 3.5
Population data: 101 counties
fips county_name state population
0 06037 Los Angeles County CA 9829544
1 17031 Cook County IL 5173146
2 48201 Harris County TX 4728030
3 04013 Maricopa County AZ 4496588
4 06073 San Diego County CA 3276208
Gini data: 101 counties
fips county_name state gini
0 06037 Los Angeles County CA 0.507
1 17031 Cook County IL 0.504
2 48201 Harris County TX 0.498
3 04013 Maricopa County AZ 0.460
4 06073 San Diego County CA 0.465
Drug offense data: 101 counties
fips county_name state drug_offense_rate
0 06037 Los Angeles County CA 320.0
1 17031 Cook County IL 580.0
2 48201 Harris County TX 490.0
3 04013 Maricopa County AZ 420.0
4 06073 San Diego County CA 340.0
Poverty data: 101 counties
fips county_name state poverty_rate
0 06037 Los Angeles County CA 14.2
1 17031 Cook County IL 13.1
2 48201 Harris County TX 15.8
3 04013 Maricopa County AZ 13.5
4 06073 San Diego County CA 11.8
Income data: 101 counties
fips county_name state median_income
0 06037 Los Angeles County CA 75235
1 17031 Cook County IL 72231
2 48201 Harris County TX 63802
3 04013 Maricopa County AZ 72850
4 06073 San Diego County CA 88240
Gun ownership data: 101 counties
fips county_name state gun_ownership_pct
0 06037 Los Angeles County CA 28.3
1 17031 Cook County IL 27.8
2 48201 Harris County TX 45.7
3 04013 Maricopa County AZ 46.3
4 06073 San Diego County CA 28.3
Giffords grade data: 101 counties
fips county_name state giffords_grade giffords_numeric
0 06037 Los Angeles County CA A 11
1 17031 Cook County IL A 11
2 48201 Harris County TX F 0
3 04013 Maricopa County AZ F 0
4 06073 San Diego County CA A 11

Merge All Datasets

Merged dataset: 101 counties
fips county_name state gun_homicide_rate population gini drug_offense_rate poverty_rate median_income gun_ownership_pct giffords_grade giffords_numeric region
0 06037 Los Angeles County CA 7.2 9829544 0.507 320.0 14.2 75235 28.3 A 11 West
1 17031 Cook County IL 14.5 5173146 0.504 580.0 13.1 72231 27.8 A 11 Midwest
2 48201 Harris County TX 12.8 4728030 0.498 490.0 15.8 63802 45.7 F 0 South
3 04013 Maricopa County AZ 7.1 4496588 0.460 420.0 13.5 72850 46.3 F 0 West
4 06073 San Diego County CA 3.5 3276208 0.465 340.0 11.8 88240 28.3 A 11 West
5 06059 Orange County CA 1.8 3162245 0.465 260.0 9.1 104419 28.3 A 11 West
6 12086 Miami-Dade County FL 10.2 2701767 0.512 410.0 16.5 57815 35.3 D 2 South
7 48113 Dallas County TX 11.4 2613539 0.504 470.0 15.3 62081 45.7 F 0 South
8 36047 Kings County NY 4.8 2559903 0.512 290.0 19.2 66850 19.9 A 11 Northeast
9 06065 Riverside County CA 5.6 2418185 0.435 380.0 13.4 73260 28.3 A 11 West

Data Coverage Summary

Counties with ALL metrics: 101

Metric Counties with data
0 Gun Homicide Rate 101
1 Population 101
2 Gini Coefficient 101
3 Drug Offense Rate 101
4 Poverty Rate 101
5 Median Income 101
6 Gun Ownership % 101
7 Giffords Grade 101

Save Merged Dataset

Saved merged data to ../data/processed/merged_us_county_data.csv
Shape: (101, 13)
gun_homicide_rate population gini drug_offense_rate poverty_rate median_income gun_ownership_pct giffords_numeric
count 101.000000 1.010000e+02 101.000000 101.000000 101.000000 101.000000 101.000000 101.000000
mean 8.297030 1.244821e+06 0.469515 397.524752 13.940594 70647.306931 39.711881 4.960396
std 6.927748 1.272756e+06 0.039671 119.602725 4.976247 20091.026633 12.617974 4.855761
min 0.700000 9.950000e+04 0.393000 150.000000 5.100000 39820.000000 8.100000 0.000000
25% 3.400000 5.707190e+05 0.441000 310.000000 10.200000 57350.000000 28.300000 0.000000
50% 6.200000 9.211300e+05 0.469000 390.000000 13.500000 67850.000000 44.400000 2.000000
75% 11.400000 1.459762e+06 0.496000 480.000000 16.500000 76215.000000 47.900000 11.000000
max 34.200000 9.829544e+06 0.600000 720.000000 28.600000 140258.000000 66.300000 11.000000

Us Gun Homicide Map

09 — US County Gun Homicide Rate Map

County-level choropleth map of gun homicide rates per 100K, plus top/bottom 20 bar charts.

Loaded 101 counties

County Choropleth — Gun Homicide Rate per 100K

Summary Statistics

Gun Homicide Rate (per 100K) — Summary Statistics
  Mean:   8.30
  Median: 6.20
  Std:    6.93
  Min:    0.70 (Middlesex County, MA)
  Max:    34.20 (Baltimore City, MD)

Top 20 Counties by Gun Homicide Rate

Bottom 20 Counties (Lowest Gun Homicide Rate)


Us Gini Correlation

10 — US County: Gun Homicide vs Gini Coefficient

Scatter plot with trend line exploring the correlation between income inequality (Gini)

and gun homicide rates across ~100 of the largest US counties.

Counties with both Gini and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Gini Coefficient

Linear regression (Gini vs log10 gun homicide rate):
  R² = 0.3259
  p-value = 4.58e-10
  slope = 5.4341

Gini Coefficient Choropleth (US Counties)


Us Drug Correlation

11 — US County: Gun Homicide vs Drug Offense Rate

Scatter plot with trend line exploring the correlation between drug offense rates

and gun homicide rates across ~100 of the largest US counties.

Counties with both drug offense and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Drug Offense Rate

Linear regression (drug offense rate vs log10 gun homicide rate):
  R² = 0.8822
  p-value = 8.99e-48
  slope = 0.002966

Drug Offense Rate Choropleth (US Counties)


Us Population Correlation

12 — US County: Gun Homicide vs Population

Scatter plot with trend line exploring the correlation between population size

and gun homicide rates across ~100 of the largest US counties.

Counties with both population and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Population (log-log)

Linear regression (log10 population vs log10 gun homicide rate):
  R² = 0.0026
  p-value = 6.13e-01
  slope = 0.0549

Us Poverty Correlation

13 — US County: Gun Homicide vs Poverty Rate

Scatter plot with trend line exploring the correlation between poverty rate

and gun homicide rates across ~100 of the largest US counties.

Counties with both poverty and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Poverty Rate

Linear regression (poverty rate vs log10 gun homicide rate):
  R² = 0.4625
  p-value = 5.26e-15
  slope = 0.0516

Poverty Rate Choropleth (US Counties)


Us Income Correlation

14 — US County: Gun Homicide vs Median Household Income

Scatter plot with trend line exploring the correlation between median household income

and gun homicide rates across ~100 of the largest US counties.

Counties with both income and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Median Household Income

Linear regression (median income vs log10 gun homicide rate):
  R² = 0.4175
  p-value = 2.94e-13
  slope = -0.00001215

Median Household Income Choropleth (US Counties)


Us Gun Ownership Correlation

15 — US County: Gun Homicide vs Gun Ownership

Scatter plot with trend line exploring the correlation between gun ownership rates

and gun homicide rates across ~100 of the largest US counties.

**Caveat:** Gun ownership data is a *state-level proxy* from RAND Corporation estimates.

Multiple counties in the same state share the same x-value, which creates visible

clustering in the scatter plot.

Counties with both gun ownership and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Gun Ownership %

Linear regression (gun ownership % vs log10 gun homicide rate):
  R² = 0.0389
  p-value = 4.81e-02
  slope = 0.0059

Gun Ownership Choropleth (US Counties, state-level proxy)


Us Gun Control Correlation

16 — US County: Gun Homicide vs Gun Control (Giffords Grade)

Scatter plot, strip/box plot, and choropleth exploring the correlation between

state gun law grades (Giffords Law Center) and county gun homicide rates.

**Caveat:** Giffords grades are *state-level* — all counties in a state share the same grade.

**Scale:** F=0, D-=1, D=2, D+=3, C-=4, C=5, C+=6, B-=7, B=8, B+=9, A-=10, A=11, A+=12

Counties with both Giffords grade and gun homicide data: 101

Scatter Plot — Gun Homicide Rate vs Giffords Numeric Score

Linear regression (Giffords numeric vs log10 gun homicide rate):
  R² = 0.0906
  p-value = 2.22e-03
  slope = -0.0234

Strip / Box Plot — Homicide Rate Distribution by Giffords Grade

Giffords Grade Choropleth (US Counties, state-level proxy)